﻿var notifyCarInfo = ""; //浮动标签显示
var carListGrid; //实时监控列表
var toiletListStore; //实时监控列表-公厕
var carListStoreRecord; //实时监控对象
var carListStore; //实时监控数据源
var carListStoreBuf; //表里显示的监控数据源
var rsmCarList; //选中行
var taskLoadCarList; //实时获取数据timer
var taskLoadCarListBuf; //没用
var carGroupList; //分组下拉列表
var rtStatisticsGrid; //实时统计列表 zx 2019.10.10
//全部车辆
var allCount = new Ext.form.Label();
//在线车辆
var onlineCount = new Ext.form.Label();
var realTimeWindow;
var realTimeAreaID;

var isCLC;
var isNCD;
var isZZZ;
var isCY;
var isXQCY;

var currentToiletTadID;

function createCarListPanel() {
    
    carListStoreBuf = createCarListStore();

    //carListStoreBuf.addListener('add', function(store, records, index) {
    carListStoreBuf.on('add', function (store, records, index) {
        //    var curZoom = window.frames["monitor"].curMapZoom();
        //    if(curZoom > 13) {
        a = records.length;
        if (monitorLoaded == 1) {
            if (records.length > 0) {
                var record = records[0];

                var licensePlate = record.get('LicensePlate');
                var cardNo = record.get('CardNo');
                var status = record.get('Status');
                var speed = record.get('Speed');
                var direction = record.get('Direction');
                var gpsTime = record.get('GpsTime');
                var lng = record.get('Lng');
                var lat = record.get('Lat');
                var lngOffset = record.get('LngOffset');
                var latOffset = record.get('LatOffset');
                var TemperatureRT = record.get('TemperatureRT');
                var carType = record.get("CarType");
                var iconName = 'car0.gif';
                if (carType == "自卸车" || carType == "有害垃圾车" || carType == "小型垃圾车" || carType == "小型机扫车" || carType == "洗路车" || carType == "吸粪车" || carType == "吸尘车" || carType == "洒水车" || carType == "挤压车" || carType == "机扫车" || carType == "勾臂车" || carType == "高压清洗车" || carType == "除雪车" || carType == "餐厨车") {
                    iconName = getDirectionIconNameWithType(direction, carType);
                } else if (carType == "手机") {
                    iconName = 'mobile.png';
                } else if (carType == "班组长") {
                    iconName = '班组长/bzz' + status + '.png';
                } else if (carType == "环卫工" || carType == "维保工人") {
                    iconName = '环卫工人/hwg' + status + '.png';
                } else if (carType.indexOf("公厕") != -1) {
                    iconName = 'Toilet.bmp';
                } else { }

                var overText = "<B><font color='#ff6600'>" + licensePlate + "</font></B><BR><div id='meuncontl' style='text-decoration:none'></div>卡号:" + cardNo + "<BR>" + "状态:" + getStatusName(status) + "<BR>" + "速度:" + speed + "公里/小时<BR>" + "方向:" + getDirectionName(direction) + "<br>" + "时间:" + gpsTime + "<BR>" + "经度:" + lng + "<BR>纬度:" + lat;

                window.frames["monitor"].createfontmarkerEx(lng, lat, licensePlate, iconName, overText);
            }
            //        }
        }
    });

    carListStoreBuf.addListener('update', function (store, record, operation) {

        if (monitorLoaded == 1) {
            var licensePlate = record.get('LicensePlate');
            var cardNo = record.get('CardNo');
            var status = record.get('Status');
            var speed = record.get('Speed');
            var direction = record.get('Direction');
            var gpsTime = record.get('GpsTime');
            var lng = record.get('Lng');
            var lat = record.get('Lat');
            var lngOffset = record.get('LngOffset');
            var latOffset = record.get('LatOffset');
            var Location = record.get('Location');
            var TemperatureRT = record.get('TemperatureRT');

            //20120524 WUP 修改手机图标更新成车辆图标
            if (record.get("CarType") == "手机") {
                window.frames["monitor"].setIconName(cardNo, 'mobile.png');
            }
            else {
                window.frames["monitor"].setIconName(cardNo, getDirectionIconNameWithType(record.get("Direction"), record.get("CarType")));
            }

            var overText = "<B><font color='#ff6600'>" + licensePlate + "</font></B><BR><div id='meuncontl' style='text-decoration:none'></div>号:" + cardNo + "<BR>" + "状态:" + getStatusName(status) + "<BR>" + "速度:" + speed + "公里/小时<BR>" + "方向:" + getDirectionName(direction) + "<br>" + "时间:" + gpsTime + "<BR>" + "经度:" + lng + "<BR>纬度:" + lat;



            if (record.get('VID') == curVID) {

                window.frames["monitor"].setLatLngMonitorEx(lng, lat, cardNo, overText);
            }
            else {
                window.frames["monitor"].setLatLngEx(lng, lat, cardNo, overText);
            }

            //            loopGetAddr(record);
        }
    });

    carListStore = createCarListStore();

    rsmCarList = new Ext.grid.RowSelectionModel({
        singleSelect: true//只允许单选
    });

    if (currentService == 6) {
        carListGrid = new Ext.grid.GridPanel({
            autoSort: true,
            height: 150,
            columns: [
	new Ext.grid.RowNumberer({
	    id: 'VID',
	    header: "",
	    renderer: function (value, metadata, record, rowIndex) {
	        if (record.get("Status") == 0) {
	            return "<img src='images/terminalstate.gif' title='在线'>";
	        }
	        else if (record.get("Status") == 6) {
	            return "<img src='images/terminalstate2.gif' title='离线'>";
	        }
	        else {
	            return "<img src='images/terminalstate3.gif' title='报警'>";
	        }
	    }
	}),
    { header: "数据类型", sortable: true, dataIndex: "ssection16", width: 60 },
	        { header: "编号", sortable: true, dataIndex: "VID", width: 60 },
            { header: "组织编号", sortable: true, dataIndex: "ClientNo" },
	        { header: "分组", sortable: true, dataIndex: "ClientName" },
	        { header: "名称", sortable: true, dataIndex: "LicensePlate", width: 150 },
	        { header: "通讯卡号", sortable: false, dataIndex: "CardNo", width: 100 },
            { header: "类型", sortable: true, dataIndex: "CarType", width: 100 },
            { header: "最终定位时间", sortable: true, dataIndex: "GpsTime", width: 150 },
	        { header: "经度", sortable: false, dataIndex: "Lng", width: 100 },
	        { header: "纬度", sortable: false, dataIndex: "Lat", width: 100 },
	        { header: "速度", sortable: true, dataIndex: "Speed", width: 100 },
	        { header: "方向", sortable: false, dataIndex: "Direction", renderer: getDirectionName, width: 100 },
            { header: "位置", sortable: true, dataIndex: "Location", width: 200 },
            { header: "状态", sortable: true, dataIndex: "Status", renderer: getStatusName, width: 60 },
	        { header: "性别", sortable: true, dataIndex: "ssection1", width: 50 },
	        { header: "心跳", sortable: true, dataIndex: "ssection2", width: 60 },
	        { header: "电话", sortable: true, dataIndex: "ssection3", width: 100 },
            { header: "生日", sortable: true, dataIndex: "ssection14", width: 100 },
            { header: "入职时间", sortable: true, dataIndex: "ssection15", width: 100 },
	        { header: "所属镇", sortable: true, dataIndex: "ssection4", width: 200 },
            { header: "所属村", sortable: true, dataIndex: "ssection5", width: 200 },
	        { header: "负责区域", sortable: true, dataIndex: "ssection6", width: 200 },
            { header: "设备类型", sortable: true, dataIndex: "ssection7", width: 200 },
            { header: "打卡情况", sortable: true, dataIndex: "ssection8", width: 200 },
            { header: "负责维保公厕", sortable: true, dataIndex: "LngOffset", width: 200 },
            { header: "正在维保公厕", sortable: true, dataIndex: "LatOffset", width: 200 },
            { header: "油量", sortable: true, dataIndex: "ssection9", width: 100 },
            { header: "作业状态", sortable: true, dataIndex: "ssection10", width: 100 },
            { header: "扩展状态", sortable: true, dataIndex: "ssection11", width: 100 },
            { header: "指令应答", sortable: true, dataIndex: "ssection12", width: 100 },
            { header: "唯一标识码", sortable: true, dataIndex: "ssection13", width: 100 }
            //{ header: "实时电话", sortable: true, dataIndex: "TemperatureRT", renderer: getTemperatureRT, width性别80 }//2019.09 zx
            //{ header: "偏移经度", sortable: true, dataIndex: "LngOff负责区域, width: 100 },
            //{ header: "偏移纬度", sortable: true, dataIndex: "LatOffset", width: 100 }
        ],
            store: carListStoreBuf,
            sm: rsmCarList
        });
    } else if (currentService == 5) {
        carListGrid = new Ext.grid.GridPanel({
            autoSort: true,
            height: 150,
            columns: [
	new Ext.grid.RowNumberer({
	    id: 'VID',
	    header: "",
	    renderer: function (value, metadata, record, rowIndex) {
	        if (record.get("Status") == 0) {
	            return "<img src='images/terminalstate.gif' title='在线'>";
	        }
	        else if (record.get("Status") == 6) {
	            return "<img src='images/terminalstate2.gif' title='离线'>";
	        }
	        else {
	            return "<img src='images/terminalstate3.gif' title='报警'>";
	        }
	    }
	}),
    { header: "数据类型", sortable: true, dataIndex: "ssection16", width: 60 },
	        { header: "编号", sortable: true, dataIndex: "VID", width: 60 },
            { header: "组织编号", sortable: true, dataIndex: "ClientNo" },
	        { header: "分组", sortable: true, dataIndex: "ClientName" },
	        { header: "名称", sortable: true, dataIndex: "LicensePlate", width: 150 },
	        { header: "通讯卡号", sortable: false, dataIndex: "CardNo", width: 100 },
            { header: "类型", sortable: true, dataIndex: "CarType", width: 100 },
            { header: "最终定位时间", sortable: true, dataIndex: "GpsTime", width: 150 },
	        { header: "经度", sortable: false, dataIndex: "Lng", width: 100 },
	        { header: "纬度", sortable: false, dataIndex: "Lat", width: 100 },
	        { header: "速度", sortable: true, dataIndex: "Speed", width: 100 },
	        { header: "方向", sortable: false, dataIndex: "Direction", renderer: getDirectionName, width: 100 },
            { header: "位置", sortable: true, dataIndex: "Location", width: 200 },
            { header: "状态", sortable: true, dataIndex: "Status", renderer: getStatusName, width: 60 },
	        { header: "性别", sortable: true, dataIndex: "ssection1", width: 50 },
	        { header: "心跳", sortable: true, dataIndex: "ssection2", width: 60 },
	        { header: "电话", sortable: true, dataIndex: "ssection3", width: 100 },
            { header: "生日", sortable: true, dataIndex: "ssection14", width: 100 },
            { header: "入职时间", sortable: true, dataIndex: "ssection15", width: 100 },
	        { header: "所属镇", sortable: true, dataIndex: "ssection4", width: 200 },
            { header: "所属村", sortable: true, dataIndex: "ssection5", width: 200 },
	        { header: "负责区域", sortable: true, dataIndex: "ssection6", width: 200 },
            { header: "设备类型", sortable: true, dataIndex: "ssection7", width: 200 },
            { header: "打卡情况", sortable: true, dataIndex: "ssection8", width: 200 },
            { header: "油量", sortable: true, dataIndex: "ssection9", width: 200 },
            { header: "作业状态", sortable: true, dataIndex: "ssection10", width: 200 },
            { header: "扩展状态", sortable: true, dataIndex: "ssection11", width: 200 },
            { header: "指令应答", sortable: true, dataIndex: "ssection12", width: 200 },
            { header: "唯一标识码", sortable: true, dataIndex: "ssection13", width: 200 }
            //{ header: "实时电话", sortable: true, dataIndex: "TemperatureRT", renderer: getTemperatureRT, width性别80 }//2019.09 zx
            //{ header: "偏移经度", sortable: true, dataIndex: "LngOff负责区域, width: 100 },
            //{ header: "偏移纬度", sortable: true, dataIndex: "LatOffset", width: 100 }
        ],
            store: carListStoreBuf,
            sm: rsmCarList
        });
    } else {
        carListGrid = new Ext.grid.GridPanel({
            autoSort: true,
            height: 150,
            columns: [
	new Ext.grid.RowNumberer({
	    id: 'VID',
	    header: "",
	    renderer: function (value, metadata, record, rowIndex) {
	        if (record.get("Status") == 0) {
	            return "<img src='images/terminalstate.gif' title='在线'>";
	        }
	        else if (record.get("Status") == 6) {
	            return "<img src='images/terminalstate2.gif' title='离线'>";
	        }
	        else {
	            return "<img src='images/terminalstate3.gif' title='报警'>";
	        }
	    }
	}),
	        { header: "车辆编号", sortable: true, dataIndex: "VID", width: 60 },
	        { header: "分组", sortable: true, dataIndex: "ClientName" },
	        { header: "车辆名称", sortable: true, dataIndex: "LicensePlate", width: 150 },
	        { header: "通讯卡号", sortable: false, dataIndex: "CardNo", width: 100 },
	        { header: "经度", sortable: false, dataIndex: "Lng", width: 100 },
	        { header: "纬度", sortable: false, dataIndex: "Lat", width: 100 },
	        { header: "速度", sortable: true, dataIndex: "Speed", width: 100 },
	        { header: "方向", sortable: false, dataIndex: "Direction", renderer: getDirectionName, width: 100 },
	        { header: "最终定位时间", sortable: true, dataIndex: "GpsTime", width: 150 },
	        { header: "车辆类型", sortable: true, dataIndex: "CarType", width: 100 },
	        { header: "状态", sortable: true, dataIndex: "Status", renderer: getStatusName, width: 60 },
	        { header: "位置", sortable: true, dataIndex: "Location", width: 200 }
            //{ header: "实时电话", sortable: true, dataIndex: "TemperatureRT", renderer: getTemperatureRT, width性别80 }//2019.09 zx
            //{ header: "偏移经度", sortable: true, dataIndex: "LngOff负责区域, width: 100 },
            //{ header: "偏移纬度", sortable: true, dataIndex: "LatOffset", width: 100 }
        ],
            store: carListStoreBuf,
            sm: rsmCarList
        });
    }


    carListGrid.addListener('celldblclick', function (grid, rowIndex, columnIndex, e) {//单击，可以把celldblclick换成cellclick
        if (monitorLoaded == 1) {
            var dataStore = grid.getStore();
            var myRcd = dataStore.getAt(rowIndex);
            showNotifyCarInfo(myRcd);
        }
    });
    if (currentService == 6) {
        carListGrid.addListener('rowcontextmenu', rightClickFnService6Cleaner); //右键菜单代码关键部分
        
        
        } else {
        carListGrid.addListener('rowcontextmenu', rightClickFn); //右键菜单代码关键部分
    }
    
    //carListGrid.addListener('rowdblclick', rightClickFn); //右键菜单代码关键部分 

    //    var progressBar = Ext.Msg.show({
    //        title: "请稍等",
    //        msg: "正在加载后台数据",
    //        width: 300,
    //        wait: true,
    //        waitConfig: {
    //            interval: 100, duration: 10000, fn: function () {
    //                Ext.Msg.hide();
    //            }
    //        },
    //        closable: true
    //    });

    taskLoadCarList = {
        run: Research, //执行任务时执行的函数
        interval: 10000//任务间隔，毫秒为单位，这里是10秒
    };

    Ext.TaskMgr.start(taskLoadCarList);


    //2019.09.18 zx
    function inicmbCarNum() {

        //定义一个下拉框
        return new Ext.form.Field({
            id: 'cmbLicensePlate',
            width: 180
        });
    }

    //2019.09.18 zx
    function inicmbCarGroup() {
        var carGroup = [["", "全部"], ["组1", "组1"], ["组2", "组2"]];

        carGroupList = createCarGroupList();
        carGroupList.load({
            params: { clientNo: userClientNo, currentService: currentService, op: 'GetGroupList' }, //2019.09.20 zx
            autoLoad: true,
            callback: function (records, options, success) {

                carGroup = [];
                for (var i = 0; i <= records.length - 1; i++) {
                    //                for (var i = 0; i <= 3; i++) {
                    //                    carGroup.push([records[i].get("CLIENT_NO"), records[i].get("CLIENT_NAME")]);
                    if (i == 0) {
                        carGroup.push(["", records[i].get("CLIENT_NAME")]);
                    } else {
                        carGroup.push([records[i].get("CLIENT_NO"), records[i].get("CLIENT_NAME")]);
                    }
                }

                //          alert(carGroup);
                //        carGroup = [["", "全部"], [records[0].get("CLIENT_NO"), records[0].get("CLIENT_NAME")], [records[1].get("CLIENT_NO"), records[1].get("CLIENT_NAME")]];
                var proxy = new Ext.data.MemoryProxy(carGroup);
                var Type_Car = Ext.data.Record.create([{ name: "cid", type: "string", mapping: 0 }, { name: "cname", type: "string", mapping: 1}]);
                var reader = new Ext.data.ArrayReader({}, Type_Car);
                var store = new Ext.data.Store({
                    proxy: proxy,
                    reader: reader//,
                    //autoLoad:true
                });
                store.load();
                Ext.getCmp('cmbCarGroup').store = store;
                Ext.getCmp("cmbCarGroup").setValue("");
            }
        });
        var proxy = new Ext.data.MemoryProxy(carGroup);
        var Type_Car = Ext.data.Record.create([{ name: "cid", type: "string", mapping: 0 }, { name: "cname", type: "string", mapping: 1}]);
        var reader = new Ext.data.ArrayReader({}, Type_Car);
        var store = new Ext.data.Store({
            proxy: proxy,
            reader: reader//,
            //autoLoad:true
        });
        store.load();
        //定义一个下拉框
        var cmbCarGroup = new Ext.form.ComboBox({
            fieldLabel: '分组',
            id: 'cmbCarGroup',
            widsth: 100,
            allowBlank: false,
            triggerAction: "all", //是否开启自动查询功能
            store: store, //定义数据源
            displayField: "cname", //关联某一个逻辑列名作为显示值
            valueField: "cid", //关联某一个逻辑列名作为实际值
            mode: "local", //如果数据来自本地用local 如果来自远程用remote默认为remote
            emptyText: "请选择分组"//没有选择时候的默认值

        });
        Ext.getCmp("cmbCarGroup").setValue("");
        return cmbCarGroup;
    }

    //2019.09.18 zx
    function inicmbCarState() {

        //var carState = [["全部", "全部"], ["在线", "在线"], ["离线", "离线"]];
        var carState = [["1", "全部"], ["0", "在线"], ["6", "离线"]];
        var proxy = new Ext.data.MemoryProxy(carState);
        var Type_Car = Ext.data.Record.create([{ name: "cid", type: "string", mapping: 0 }, { name: "cname", type: "string", mapping: 1}]);
        var reader = new Ext.data.ArrayReader({}, Type_Car);
        var store = new Ext.data.Store({
            proxy: proxy,
            reader: reader//,
            //autoLoad:true
        });
        store.load();
        //定义一个下拉框
        var cmbCarState = new Ext.form.ComboBox({
            fieldLabel: '状态',
            id: 'cmbCarState',
            width: 100,
            allowBlank: false,
            triggerAction: "all", //是否开启自动查询功能
            store: store, //定义数据源
            displayField: "cname", //关联某一个逻辑列名作为显示值
            valueField: "cid", //关联某一个逻辑列名作为实际值
            mode: "local", //如果数据来自本地用local 如果来自远程用remote默认为remote
            emptyText: "请选择状态"//没有选择时候的默认值

        });
        Ext.getCmp("cmbCarState").setValue("0");
        return cmbCarState;
    }

    //2018.07.23 houruixian
    function inicmbCarFLAG() {
        var carType = [["", "全部"]];
        if (currentService == 1) {
            carType = [["", "全部"], ["机扫车", "机扫车"], ["小型机扫车", "小型机扫车"], ["吸尘车", "吸尘车"], ["洒水车", "洒水车"], ["高压清洗车", "高压清洗车"], ["洗路车", "洗路车"], ["除雪车", "除雪车"]];
        }
        if (currentService == 3) {
            carType = [["", "全部"], ["挤压车", "挤压车"], ["小型垃圾车", "小型垃圾车"], ["自卸车", "自卸车"], ["勾臂车", "勾臂车"], ["餐厨车", "餐厨车"], ["吸粪车", "吸粪车"], ["有害垃圾车", "有害垃圾车"]];
        }
        if (currentService == 5) {
            carType = [["", "全部"], ["班组长", "班组长"], ["环卫工人", "环卫工人"], ["机扫车", "机扫车"], ["小型机扫车", "小型机扫车"], ["吸尘车", "吸尘车"], ["洒水车", "洒水车"], ["高压清洗车", "高压清洗车"], ["洗路车", "洗路车"], ["除雪车", "除雪车"], ["挤压车", "挤压车"], ["小型垃圾车", "小型垃圾车"], ["自卸车", "自卸车"], ["勾臂车", "勾臂车"], ["餐厨车", "餐厨车"], ["吸粪车", "吸粪车"], ["有害垃圾车", "有害垃圾车"]];
        }
        var proxy = new Ext.data.MemoryProxy(carType);
        var Type_Car = Ext.data.Record.create([{ name: "cid", type: "string", mapping: 0 }, { name: "cname", type: "string", mapping: 1}]);
        var reader = new Ext.data.ArrayReader({}, Type_Car);
        var store = new Ext.data.Store({
            proxy: proxy,
            reader: reader//,
            //autoLoad:true
        });
        store.load();
        //定义一个下拉框
        var cmbCarType = new Ext.form.ComboBox({
            fieldLabel: '类别',
            id: 'cmbCarType',
            width: 180,
            allowBlank: false,
            triggerAction: "all", //是否开启自动查询功能
            store: store, //定义数据源
            displayField: "cname", //关联某一个逻辑列名作为显示值
            valueField: "cid", //关联某一个逻辑列名作为实际值
            mode: "local", //如果数据来自本地用local 如果来自远程用remote默认为remote
            emptyText: "请选择类别"//没有选择时候的默认值

        });
        Ext.getCmp("cmbCarType").setValue("");
        return cmbCarType;
    }


    function inicmbShowEchart() {
//        if (currentService == 3 || currentService == 1) {
            return {
                icon: "images/2411.png", text: "一张图",
                handler: showEcharts
            };
//        }
//        return "";
    }

    //2018.07.23 houruixian
    function inicmbShowPlaceMenu() {
        if (currentService == 3 || currentService == 5) {
            return {
                text: "垃圾收集点显示",
                menu: new Ext.menu.Menu({
                    items: [
	                       { text: "中转站", handler: showPlaceOnMapZZZ, checked: false },
	                       { text: "处理厂", handler: showPlaceOnMapCLC, checked: false },
                           { text: "农村点", handler: showPlaceOnMapNCD, checked: false },
                           { text: "餐饮", handler: showPlaceOnMapCY, checked: false },
                           { text: "小区厨余", handler: showPlaceOnMapXQCY, checked: false },
                           { text: "小区其他", handler: showPlaceOnMapXQQT, checked: false }
                        ]
                })
            };
        }
        return "";
    }

    function realTimeStatisticsGetVehicleCurrentInfoDistrict() {
        var carCountStore = CreateVehicleCurrentInfoDistrict();
        carCountStore.load({
            params: { clientNo: userClientNo, currentService: currentService, op: 'GetVehicleCurrentInfoDistrict' }, //2019.09.20 zx
            callback: function (records, options, success) {
                var carCountGrid = new Ext.grid.GridPanel({
                    autoSort: true,
                    height: 150,
                    columns: [
                new Ext.grid.RowNumberer({
                    header: "",
                    renderer: function (value, metadata, record, rowIndex) {

                    }
                }),
                        { header: "类型", sortable: true, dataIndex: "type", width: 120 },
                        { header: "在线车辆", sortable: true, dataIndex: "carCountOnline", width: 120 },
                        { header: "全部车辆", sortable: true, dataIndex: "carCountAll", width: 120 }
                    ],
                    store: carCountStore
                });

                var window = new Ext.Window({
                    layout: 'fit',       //弹出窗口内布局会充满整个窗口;
                    width: 500,          //设置窗口大小;
                    height: 300,
                    items: carCountGrid         //默认会生成Ext.Panel类型的对象;并且随窗口大小改变而改变;
                });
                window.show();
            }
        });
    }

    //2018.07.23 houruixian
    function Research() {
        /*
        if (Ext.get('cmbCarType').getValue() == "请选择类别") {
        Ext.MessageBox.alert("提示", "请选择类别");
        return;
        }
        */
        //20190920 zx 已经修改数据库为不传参数不筛选
        carListStoreLoad();
        toiletListStoreLoad();
    }

    function returnItemForList() {
        if (currentService == 6) {
        toiletListStore = new Ext.data.Store({
            url: "./Json/JsonGetToiletInfoList.ashx",
            reader: new Ext.data.JsonReader(
                { root: 'data' },
                Ext.data.Record.create([{ name: 'LicensePlate' }, { name: 'Location' }, { name: 'section3' }, { name: 'CarType' }, { name: 'section5' }, { name: 'section6' }, { name: 'section7' }, { name: 'section8' }, { name: 'section9' }, { name: 'section10' }, { name: 'Lng' }, { name: 'Lat' }, { name: 'section13' }, { name: 'section14' }, { name: 'section15'}])
            )
        });
        var toiletListGrid = new Ext.grid.GridPanel({
            columns: [
	{ header: "公厕名称", dataIndex: "LicensePlate", width: 120 },
    { header: "公厕位置", dataIndex: "Location", width: 200 },
    { header: "建筑类别", dataIndex: "section3", width: 100 },
    { header: "公厕类型", dataIndex: "CarType", width: 100 },
    { header: "开放时间", dataIndex: "section5", width: 100 },
    { header: "男蹲位总数", dataIndex: "section6", width: 100 },
    { header: "男蹲位剩余数", dataIndex: "section7", width: 100 },
    { header: "女蹲位总数", dataIndex: "section8", width: 100 },
    { header: "女蹲位剩余数", dataIndex: "section9", width: 100 },
    { header: "公厕编号", dataIndex: "section10", width: 100 },
    { header: "经度", dataIndex: "Lng", width: 100 },
    { header: "纬度", dataIndex: "Lat", width: 100 },
    { header: "组织编号", dataIndex: "section13", width: 100 },
    { header: "正在维保人员", dataIndex: "section14", width: 100 },
    { header: "缺纸情况", dataIndex: "section15", width: 200 }
	],
            store: toiletListStore
        });


        toiletListGrid.addListener('celldblclick', function (grid, rowIndex, columnIndex, e) {//单击，可以把celldblclick换成cellclick
            if (monitorLoaded == 1) {
                var dataStore = grid.getStore();
                var rcd = dataStore.getAt(rowIndex);

//                var notifyCarInfo = "<B><font color='#CC9900'>" + rcd.get('LICENSE_PLATE') + "</font></B><BR><div id='meuncontl' style='text-decoration:none'></div>报警时间: " + rcd.get('ALARM_TIME') + "<BR>" + "报警类型: " + GetAlarmTypeString(rcd.get('ALARM_TYPE')) + "<BR>地址：解析中<br>&nbsp;";
                var notifyCarInfo = "<B><font color='#CC9900'>" + rcd.get('LicensePlate') + "</font></B><BR><div id='meuncontl' style='text-decoration:none'></div>公厕位置:" + rcd.get('Location') + "<BR>" + "公厕类型:" + rcd.get('CarType');

                //                if (monitortype == 2) {
                window.frames["monitor"].setterminalinfo(notifyCarInfo);
                window.frames["monitor"].setinfowindow_state(1);
                window.frames["monitor"].setCenter(rcd.get('Lng'), rcd.get('Lat'));
                window.frames["monitor"].getAddress(rcd.get('Lng'), rcd.get('Lat'), 1, false);
                //20120524 WUP 修改手机图标更新成车辆图标
                //                    if (rcd.get("CarType") == "手机") {
                //                window.frames["monitor"].createMarkerALARM(rcd.get('LONGITUDE'), rcd.get('LATITUDE'));
                window.frames["monitor"].setIconName(rcd.get('CardNo'), getDirectionIconNameWithType(rcd.get("Direction"), rcd.get("CarType")));
                window.frames["monitor"].resetLatLng(rcd.get('Lng'), rcd.get('Lat'), rcd.get('CardNo'), notifyCarInfo);
            }
        });
//            toiletListGrid.addListener('rowcontextmenu', rightClickFnService6Toilet);
            return new Ext.TabPanel({
                border: false, // already wrapped so don't add another border
                activeTab: 0, // second tab initially active
                tabPosition: 'bottom',
                items: [{
                    //html: '<p>A TabPanel component can be a region.</p>',
                    //contentEl: 'Unrecognized',
                    title: '人员实时监控',
                    //autoScroll: true,
                    id: "1",
                    layout: 'fit',
                    items: carListGrid
                }, {
                    //html: '<p>b TabPanel component can be a region.</p>',
                    //contentEl: 'Confirmed',
                    title: '公厕实时监控',
                    //autoScroll: true
                    id: "2",
                    layout: 'fit',
                    items: toiletListGrid
                }],
                listeners: {
                    'tabchange': function (t, n) {
                        currentToiletTadID = n.id;
                        Research();
                        //                        alert(n.id);
                        //                        if (n.id == "1") {
                        //                            allCount.setText("人数：" + carListStore.getCount());
                        //                        } else {
                        //                            allCount.setText("公厕数：" + toiletListStore.getCount());
                        //                        }
                    }
                }
            });
        } else {
            return carListGrid;
        }
    }

    return new Ext.Panel({
        region: "south",
        height: 180,
        split: true,
        collapsible: true,
        //html: '<div id="hello"></div>',
        //contentEl: 'hello',
        layout: 'fit',
        //        items: [carListGrid],
        items: returnItemForList(),
        title: "实时数据",
        tbar: [" ", " ", " ", " ", " ", " ", "车牌号：", inicmbCarNum(), " ", "分组：", inicmbCarGroup(), " ", "状态：", inicmbCarState(), " ", "类型：", inicmbCarFLAG(), " ",
        {
            icon: "images/26006.png", text: "查询",
            handler: Research,
            tooltip: "",
            tooltipType: "title"
        }, " ", " ", " ", " ",
        //        "在线车辆：", onlineCount, " ", "    /     全部车辆：",
         allCount, inicmbShowPlaceMenu(),

//         '->', " ", " ", " "
//         , {
//                         icon: "images/acceptcheck.png", text: "",
//                         handler: function () {
//                             if (Ext.getCmp('app-car-panel') == null) {
//                                 if (GID != "") {
//                                     var carQueryPanel = createCarQueryPanel();
//                                     mapPanel.add(carQueryPanel);
//                                 }
//                                 else {
//                                     Ext.MessageBox.alert('提示', '请先选择相应的赛事!');
//                                 }
//                             }
//                             mapPanel.setActiveTab('app-car-panel');
//                         },
//                         tooltip: "查询人员", tooltipType: "title"
//                     }
        ]
    });


}

function closeCarPanel() {
    // get a reference to the Panel that was created with id = 'west-panel'
    var AP = Ext.getCmp('app-car-panel');
    if (AP != null) {
        AP.destroy();
    }
}

function carListStoreLoad() {
    carListStore.load({
        //params: { clientNo: userClientNo, carType: Ext.getCmp('cmbCarType').getValue() }, //2018.07.23 houruixian查询条件添加车辆类型 carType: Ext.getCmp('cmbCarType').getValue()
        params: { clientNo: userClientNo, currentService: currentService, licensePlate: Ext.get('cmbLicensePlate').getValue(), carGroup: Ext.getCmp('cmbCarGroup').getValue(), status: Ext.getCmp('cmbCarState').getValue(), carType: Ext.getCmp('cmbCarType').getValue(), op: 'carListCurrentVehicle' }, //2019.09.20 zx
        callback: function (records, options, success) {

            //            onlineCount.setText("" + records.length);//2018.07.23 houruixian 全部在线车辆
            callbackStoreBuf(records, options, success);
        }
    });
}

function toiletListStoreLoad() {
    if (currentService != "6") {
        return;
    }
    //    toiletListStore.removeAll();
    toiletListStore.load({
        params: { clientNo: userClientNo, op: 'GetToiletInfo' },
        callback: function (records, options, success) {
            if (currentToiletTadID == "2" && currentService == "6") {
                allCount.setText("公厕数：" + records.length);
                showPointOnMap(records);
            }

            //            onlineCount.setText("" + records.length);//2018.07.23 houruixian 全部在线车辆
            //            callbackStoreBuf(records, options, success);
        }
    });
}

function showPointOnMap(records) {
    carListStoreBuf.removeAll();
    window.frames["monitor"].clearMarkers(); //删除地图上所有图标
    window.frames["monitor"].setAllPoint(records); //海量点，只加载，不显示
    
    for (var i = 1; i <= records.length - 1; i++) {
    var record= records[i];
        var lng = record.get('Lng');
        var lat = record.get('Lat');
        var licensePlate = record.get('LicensePlate');
        var carType = record.get("CarType");


        var location = record.get('Location');
//        var status = record.get('Status');
//        var speed = record.get('Speed');
//        var direction = record.get('Direction');
//        var gpsTime = record.get('GpsTime');



        var iconName = 'car0.gif';
        if (carType == "自卸车" || carType == "有害垃圾车" || carType == "小型垃圾车" || carType == "小型机扫车" || carType == "洗路车" || carType == "吸粪车" || carType == "吸尘车" || carType == "洒水车" || carType == "挤压车" || carType == "机扫车" || carType == "勾臂车" || carType == "高压清洗车" || carType == "除雪车" || carType == "餐厨车") {
            iconName = getDirectionIconNameWithType(direction, carType);
        } else if (carType == "手机") {
            iconName = 'mobile.png';
        } else if (carType == "班组长") {
            iconName = '班组长/bzz' + status + '.png';
        } else if (carType == "环卫工" || carType == "维护工人") {
            iconName = '环卫工人/hwg' + status + '.png';
        } else if (carType.indexOf("公厕") != -1) {
            iconName = 'Toilet.bmp';
        } else { }
        var overText = "<B><font color='#ff6600'>" + licensePlate + "</font></B><BR><div id='meuncontl' style='text-decoration:none'></div>地址:" + location;
        window.frames["monitor"].createfontmarkerEx(lng, lat, licensePlate, iconName, overText);
    }
}

function callbackStoreBuf(records, options, success) {


    if (monitorLoaded == 1) {
        var carListStoreBufCount = carListStoreBuf.getCount();
        var carListStoreCount = records.length;
        if (carListStoreCount == 0) {
            //carListStoreBuf.commitChanges();//2019 zx 搜索结果为0，依然更新列表，不能还显示旧数据
            carListStoreBuf.removeAll();
            window.frames["monitor"].clearMarkers(); //删除地图上所有图标
            return;
        }
        if (carListStoreBufCount != carListStoreCount) {
            carListStoreBuf.removeAll();
            window.frames["monitor"].clearMarkers(); //删除地图上所有图标
            window.frames["monitor"].setAllPoint(records); //海量点，只加载，不显示

            for (var i = 0; i <= records.length - 1; i++) {
                //carListStoreBuf.addSorted(new carListStoreRecord({
                carListStoreBuf.add(new carListStoreRecord({
                    VID: records[i].get("VID"),
                    ClientNo: records[i].get("ClientNo"),
                    ClientName: records[i].get("ClientName"),
                    LicensePlate: records[i].get("LicensePlate"),
                    CardNo: records[i].get("CardNo"),
                    Lng: records[i].get("Lng"),
                    Lat: records[i].get("Lat"),
                    Speed: records[i].get("Speed"),
                    Direction: records[i].get("Direction"),
                    GpsTime: records[i].get("GpsTime"),
                    CarType: records[i].get("CarType"),
                    Status: records[i].get("Status"),
                    Location: records[i].get("Location"),
                    LngOffset: records[i].get("LngOffset"),
                    LatOffset: records[i].get("LatOffset"),
                    TemperatureRT: records[i].get("TemperatureRT"),
                    ssection1: records[i].get("ssection1"),
                    ssection2: records[i].get("ssection2"),
                    ssection3: records[i].get("ssection3"),
                    ssection4: records[i].get("ssection4"),
                    ssection5: records[i].get("ssection5"),
                    ssection6: records[i].get("ssection6"),
                    ssection7: records[i].get("ssection7"),
                    ssection8: records[i].get("ssection8"),
                    ssection9: records[i].get("ssection9"),
                    ssection10: records[i].get("ssection10"),
                    ssection11: records[i].get("ssection11"),
                    ssection12: records[i].get("ssection12"),
                    ssection13: records[i].get("ssection13"),
                    ssection14: records[i].get("ssection14"),
                    ssection15: records[i].get("ssection15"),
                    ssection16: records[i].get("ssection16"),
                    ssection17: records[i].get("ssection17"),
                    ssection18: records[i].get("ssection18")
                }));
            }

            if (currentService == 5) {
                allCount.setText("在线对象：" + records[0].get("LngOffset") + "  /  全部对象：" + records[0].get("LatOffset"));
            }
            if (currentService == 1 || currentService == 3) {
                allCount.setText("在线车辆：" + records[0].get("LngOffset") + "  /  全部车辆：" + records[0].get("LatOffset")); //2018.07.23 houruixian 全部车辆
            }
            if (currentToiletTadID == "1" && currentService == "6") {
                allCount.setText("人数：" + records.length);
            }
            window.frames["monitor"].mgrrefresh();
        }
        else {
            for (var i = 0; i < carListStoreCount; i++) {
                var vid = carListStore.getAt(i).get('VID');

                for (var j = 0; j < carListStoreBufCount; j++) {
                    var vidBuf = carListStoreBuf.getAt(j).get('VID');
                    if (vidBuf == vid) {
                        if (carListStoreBuf.getAt(j).get('GpsTime') != carListStore.getAt(i).get('GpsTime') || carListStoreBuf.getAt(j).get('LngOffset') != carListStore.getAt(i).get('LngOffset') || carListStoreBuf.getAt(j).get('LatOffset') != carListStore.getAt(i).get('LatOffset')) {
                            carListStoreBuf.getAt(j).set("GpsTime", carListStore.getAt(i).get('GpsTime'));
                            //carListStoreBuf.getAt(j).set("LngOffset", carListStore.getAt(i).get('LngOffset'));
                            //carListStoreBuf.getAt(j).set("LatOffset", carListStore.getAt(i).get('LatOffset'));
                            carListStoreBuf.getAt(j).set("Lng", carListStore.getAt(i).get('Lng'));
                            carListStoreBuf.getAt(j).set("Lat", carListStore.getAt(i).get('Lat'));
                            carListStoreBuf.getAt(j).set("Speed", carListStore.getAt(i).get('Speed'));
                            carListStoreBuf.getAt(j).set("Status", carListStore.getAt(i).get('Status'));
                            carListStoreBuf.getAt(j).set("Direction", carListStore.getAt(i).get('Direction'));
                            carListStoreBuf.getAt(j).set("LngOffset", carListStore.getAt(i).get('LngOffset'));
                            carListStoreBuf.getAt(j).set("LatOffset", carListStore.getAt(i).get('LatOffset'));
                            carListStoreBuf.getAt(j).set("Location", carListStore.getAt(i).get('Location'));
                            carListStoreBuf.getAt(j).set("TemperatureRT", carListStore.getAt(i).get('TemperatureRT'));
                        }
                        break;
                    }
                }
            }
            carListStoreBuf.commitChanges();
        }
    }

}

function markerclick(imei) {
    var num = carListStoreBuf.getCount();
    for (var i = 0; i <= num - 1; i++) {
        if (carListStoreBuf.getAt(i).get('CardNo') == imei) {
            rsmCarList.selectRow(i);
            var gv = carListGrid.getView();
            gv.focusRow(i);
            showNotifyCarInfo(carListStoreBuf.getAt(i));
            break;
        }
    }
}

function showNotifyCarInfo(rcd) {
    if (curVID != rcd.get('VID')) {
        document.getElementById("monitor").contentWindow.removeline();
    }

    curVID = rcd.get('VID');
    curCardNo = rcd.get('CardNo');
    curLicensePlate = rcd.get('LicensePlate');

    notifyCarInfo = "<B><font color='#CC9900'>" + curLicensePlate + "</font></B><BR><div id='meuncontl' style='text-decoration:none'></div>卡号:" + curCardNo + "<BR>" + "状态:" + getStatusName(rcd.get('Status')) + "<BR>" + "速度:" + rcd.get('Speed') + "公里/小时<BR>" + "方向:" + getDirectionName(rcd.get('Direction')) + "<br>" + "时间:" + rcd.get('GpsTime') + "<BR>" + "经纬:" + rcd.get('Lng') + "," + rcd.get('Lat') + "<BR>地址：解析中<br>&nbsp;";

    if (monitortype == 2) {
        window.frames["monitor"].setterminalinfo(notifyCarInfo);
        window.frames["monitor"].setinfowindow_state(1);
        window.frames["monitor"].setCenter(rcd.get('Lng'), rcd.get('Lat'));
        window.frames["monitor"].getAddress(rcd.get('Lng'), rcd.get('Lat'), 1, false);
        //20120524 WUP 修改手机图标更新成车辆图标
        if (rcd.get("CarType") == "手机") {
            window.frames["monitor"].setIconName(rcd.get('CardNo'), 'mobile.png');
        }
        else {
            window.frames["monitor"].setIconName(rcd.get('CardNo'), getDirectionIconNameWithType(rcd.get("Direction"), rcd.get("CarType")));
        }
        window.frames["monitor"].resetLatLng(rcd.get('Lng'), rcd.get('Lat'), rcd.get('CardNo'), notifyCarInfo);
    }
    else {
        window.frames["3dmonitor"].resetLatLng(rcd.get('Lng'), rcd.get('Lat'), curLicensePlate, notifyCarInfo);
    }
}

function getcolor(wxzt, online, endorn) {
    if (endorn == 0) {
        if (online != 0) {
            if (wxzt == 0) {
                return "#CC9900";
            } else {
                return "#009900";
            }
        } else {
            return "#575757";
        }
    } else {
        return "#FF0000";
    }
}

function startmap() {
    if (window.frames["monitor"].getstartyoun() == 1 && carListStore != null) {
        var options = 0;
        monitorLoaded = 1;
        callbackStoreBuf(carListStore.getRange(0, carListStore.getCount() - 1), options, true);
        window.frames["monitor"].initTULI(currentService);
        window.frames["monitor"].initCenter(loginUsername);
    } else {
        delayRun("startmap()", 200); //如果不延迟，会出错
        monitorLoaded = 0;
    }
}

function delayRun(code, time) {//延时执行函数
    var t = setTimeout(code, time);

}

function rightClickFnService6Toilet(carListGrid, rowindex, e) {
    if (hisPlayWin == null) {
        var dataStore = carListGrid.getStore();
        var myRcd = dataStore.getAt(rowindex);
        carListGrid.getSelectionModel().selectRow(rowindex);
        //var gettreenode = carTree.getNodeById(myRcd.get('VID'));
        //gettreenode.select();
        curVID = myRcd.get('VID');
        curCardNo = myRcd.get('CardNo');
        curLicensePlate = myRcd.get('LicensePlate');
        e.preventDefault();
        var menu = new Ext.menu.Menu({
            //控制右键菜单位置
            float: true,
            items: [{
//                id: 'rmHistoryPlay',
//                handler: historyPlay,
                text: '视频监控'
            }
     				     ]
        }).showAt(e.getXY());
    }
}

function rightClickFnService6Cleaner(carListGrid, rowindex, e) {
    if (hisPlayWin == null) {
        var dataStore = carListGrid.getStore();
        var myRcd = dataStore.getAt(rowindex);
        carListGrid.getSelectionModel().selectRow(rowindex);
        //var gettreenode = carTree.getNodeById(myRcd.get('VID'));
        //gettreenode.select();
        curVID = myRcd.get('VID');
        curCardNo = myRcd.get('CardNo');
        curLicensePlate = myRcd.get('LicensePlate');
        e.preventDefault();
        var menu = new Ext.menu.Menu({
                    	//控制右键菜单位置
     				   	float:true,
     				   	items: [{
//     				   	    id: 'rmHistoryPlay',
     				   	    handler: historyPlayOpen,
     				   	    text: '轨迹回放'
     				   	}
     				     ]
                    }).showAt(e.getXY());
    }
}

function rightClickFn(carListGrid, rowindex, e) {
    if (hisPlayWin == null) {
        var dataStore = carListGrid.getStore();
        var myRcd = dataStore.getAt(rowindex);
        carListGrid.getSelectionModel().selectRow(rowindex);
        //var gettreenode = carTree.getNodeById(myRcd.get('VID'));
        //gettreenode.select();
        curVID = myRcd.get('VID');
        curCardNo = myRcd.get('CardNo');
        curLicensePlate = myRcd.get('LicensePlate');
        e.preventDefault();
        rightMenu.showAt(e.getXY());
    }
}

function placeMenuClick() {
    //    var placeMenu =
    return Ext.create('Ext.menu', {
        id: 'rightClickCont',
        style: {
            overflow: 'visible'
        },
        items: [{
            text: '复选框',
            checked: true
        }
        ]
    });
}

//小区其他
function showPlaceOnMapXQQT() {
    if (isXQQT) {
        isXQQT = 0;
        window.frames["monitor"].removeMarkerPlaceXQQT();
    } else {
        isXQQT = 1;
        var placeData = CreatePlaceData();
        placeData.load({
            params: { clientNo: userClientNo, op: 'GetPlaceXQQT' }, //2019.09.20 zx
            autoLoad: true,
            callback: function (records, options, success) {
                if (success) {
                    for (var i = 0; i <= records.length - 1; i++) {
                        window.frames["monitor"].createMarkerPlaceXQQT(records[i].get("LONGITUDE"), records[i].get("LATITUDE"), "小区", records[i].get("Name"), "overText");
                    }
                }
            }
        });
    }

}

//小区厨余
function showPlaceOnMapXQCY() {
    if (isXQCY) {
        isXQCY = 0;
        window.frames["monitor"].removeMarkerPlaceXQCY();
    } else {
        isXQCY = 1;
        var placeData = CreatePlaceData();
        placeData.load({
            params: { clientNo: userClientNo, op: 'GetPlaceXQCY' }, //2019.09.20 zx
            autoLoad: true,
            callback: function (records, options, success) {
                if (success) {
                    for (var i = 0; i <= records.length - 1; i++) {
                        window.frames["monitor"].createMarkerPlaceXQCY(records[i].get("LONGITUDE"), records[i].get("LATITUDE"), "小区厨余", records[i].get("Name"), "overText");
                    }
                }
            }
        });
    }

}
//农村点
function showPlaceOnMapNCD() {
    if (isNCD) {
        isNCD = 0;
        window.frames["monitor"].removeMarkerPlaceNCD();
    } else {
        isNCD = 1;
        var placeData = CreatePlaceData();
        placeData.load({
            params: { clientNo: userClientNo, op: 'GetPlaceNCD' }, //2019.09.20 zx
            autoLoad: true,
            callback: function (records, options, success) {
                if (success) {
                    for (var i = 0; i <= records.length - 1; i++) {
                        window.frames["monitor"].createMarkerPlaceNCD(records[i].get("LONGITUDE"), records[i].get("LATITUDE"), "农村点", records[i].get("Name"), "overText");
                    }
                }
            }
        });
    }

}

//处理厂
function showPlaceOnMapCLC() {
    if (isCLC) {
        isCLC = 0;
        window.frames["monitor"].removeMarkerPlaceCLC();
    } else {
        isCLC = 1;
        var placeData = CreatePlaceData();
        placeData.load({
            params: { clientNo: userClientNo, op: 'GetPlaceCLC' }, //2019.09.20 zx
            autoLoad: true,
            callback: function (records, options, success) {
                if (success) {
                    for (var i = 0; i <= records.length - 1; i++) {
                        window.frames["monitor"].createMarkerPlaceCLC(records[i].get("LONGITUDE"), records[i].get("LATITUDE"), "处理厂", records[i].get("Name"), "overText");
                    }
                }
            }
        });
    }
}

//中转站
function showPlaceOnMapZZZ() {
    if (isZZZ) {
        isZZZ = 0;
        window.frames["monitor"].removeMarkerPlaceZZZ();
    } else {
        isZZZ = 1;
        var placeData = CreatePlaceData();
        placeData.load({
            params: { clientNo: userClientNo, op: 'GetPlaceZZZ' }, //2019.09.20 zx
            autoLoad: true,
            callback: function (records, options, success) {
                if (success) {
                    for (var i = 0; i <= records.length - 1; i++) {
                        window.frames["monitor"].createMarkerPlaceZZZ(records[i].get("LONGITUDE"), records[i].get("LATITUDE"), "中转站", records[i].get("Name"), "overText");
                    }
                }
            }
        });
    }
}
//餐饮
function showPlaceOnMapCY() {
    if (isCY) {
        isCY = 0;
        window.frames["monitor"].removeMarkerPlaceCY();
    } else {
        isCY = 1;
        var placeData = CreatePlaceData();
        placeData.load({
            params: { clientNo: userClientNo, op: 'GetPlaceCY' }, //2019.09.20 zx
            autoLoad: true,
            callback: function (records, options, success) {
                if (success) {
                    for (var i = 0; i <= records.length - 1; i++) {
                        window.frames["monitor"].createMarkerPlaceCY(records[i].get("LONGITUDE"), records[i].get("LATITUDE"), "餐饮", records[i].get("Name"), "overText");
                    }
                }
            }
        });
    }
}

function treeshowmenu(node, e) {
    if (hisPlayWin == null) {
        if (node.attributes.NodeType == 0) {
            curVID = node.id;
            curCardNo = node.attributes.CardNo;
            curLicensePlate = node.text;
            var coords = e.getXY();
            rightMenu.showAt([coords[0], coords[1]]);
        }
    }
}


function openAllCarVideo() {
//    var panelVideo = new Ext.Panel({
//        region: 'center',
//        id: 'app-video-panel',
//        title: '监控视频',
//        anchor: '100% 100%',
//        closable: true,
//        autoScroll: true,
//        containerScroll: true,
//        //margins: '0 0 0 5',
//        border: false,
//        iconCls: 'nav',
//        html: '<iframe src="./html/TheCarVideo.html?lang=zh&account=' + huabaoUsername + '&password=' + huabaoPassword + '&devIdno=' + '013012451021' + '" width="100%" height="100%"></iframe>'
////        html: '<iframe src="http://111.160.78.62:88/808gps/open/player/video.html?lang=zh&account=' + huabaoUsername + '&password=' + huabaoPassword + '&devIdno=13012451021" width="100%" height="100%"></iframe>'
//                            
//    });
//    mapPanel.add(panelVideo);
//    mapPanel.setActiveTab('app-video-panel');
    var videoInfo = createVideoLoginInfo();
    videoInfo.load({
        params: { clientNo: userClientNo, op: 'GetVideoLoginInfo' }, //2019.09.20 zx
        autoLoad: true,
        callback: function (records, options, success) {
            if (success) {
                var url = "http://111.160.78.62:88/808gps/index.html?account=" + records[0].get("id") + "&password=" + records[0].get("pword") + "&clientLogin=2";
                window.open(url);
            } else {
                window.open("http://111.160.78.62:88/808gps/login.html");
            }
        }
    });
}
function showEcharts() {
    var panelSelect = new Ext.Panel({
        labelAlign: 'top',
        frame: true,
        //title: '查询条件',
        bodyStyle: 'padding:0px 0px 0',
        anchor: '100% 25.5%',
        //width: 720,
        items: [{
            columnWidth: .9,
            height: 40,
            layout: { type: 'hbox' },
            items: [{ xtype: "label", width: 10, text: '' }
                , {
                    width: 50,
                    xtype: "radio",
                    name: "sex",
                    boxLabel: "当月",
                    id: "date1",
                    checked: true
                }, {
                    width: 50,
                    xtype: "radio",
                    name: "sex",
                    boxLabel: "上月",
                    id: "date2",
                    checked: true
                }]
        }, {
            columnWidth: .9,
            height: 40,
            layout: { type: 'hbox' },
            items: [{ xtype: "label", width: 10, text: '' },
                {
                    width: 60,
                    xtype: "radio",
                    name: "sex",
                    boxLabel: "按日期",
                    id: "date3"
                }, {
                    width: 150,
                    xtype: 'datefield',
                    format: 'Y-m-d',
                    id: "dateSearch",
                    value: dataDefaultCMB
                }]
            }, {
                columnWidth: .9,
                height: 40,
                layout: { type: 'hbox' },
                items: [{ xtype: "label", width: 10, text: '' },
                {
                    width: 60,
                    xtype: "radio",
                    name: "sex",
                    boxLabel: "按月份",
                    id: "date4"
                }, {
                    width: 150,
                    xtype: 'datefield',
                    format: 'Y-m',
                    id: "dateSearchMonth",
                    value: dataDefaultCMB
                }]
            }],
        buttons: [{
            text: "查询",
            name: "button",
            handler: function () {
                var dunDate;
                if (Ext.getCmp('date1').checked) {
                    var nowDate = new Date();
                    dunDate = dataFormat(nowDate, "yyyy-MM");
                }
                if (Ext.getCmp('date2').checked) {
                    var nowDate = new Date();
                    var year = nowDate.getFullYear();
                    var month = nowDate.getMonth();
                    if (month == 0) {
                        month = 12;
                        year = year - 1;
                    }
                    var lastMonth = new Date(year, month, 0);
                    dunDate = dataFormat(lastMonth, "yyyy-MM");
                }
                if (Ext.getCmp('date3').checked) {
                    if (Ext.getCmp('dateSearch').getValue() == "") {
                        Ext.MessageBox.alert("提示", "请选择日期");
                    } else {
                        dunDate = dataFormat(Ext.getCmp('dateSearch').getValue(), "yyyy-MM-dd");
                    }
                }
                if (Ext.getCmp('date4').checked) {
                    if (Ext.getCmp('dateSearchMonth').getValue() == "") {
                        Ext.MessageBox.alert("提示", "请选择月份");
                    } else {
                        dunDate = dataFormat(Ext.getCmp('dateSearchMonth').getValue(), "yyyy-MM"); ;
                    }

                }
                var url;
                if (currentService == 1) {
                    url = "http://111.160.78.62:9936/indexCar.html?user=" + loginUsername + "&date=" + dunDate;
                }
                if (currentService == 3) {
                    url = "http://111.160.78.62:9936/indexGarbage.html?user=" + loginUsername + "&date=" + dunDate;
                }
                if (currentService == 5) {
                    url = "http://111.160.78.62:9936/indexSynthesize.html?user=" + loginUsername + "&date=" + dunDate;
                }
                if (currentService == 6) {
                    url = "http://111.160.78.62:9936/indexWC.html?user=" + loginUsername + "&date=" + dunDate;
                }
                window.open(url);
            }
        }]
    });

    var windowEC = new Ext.Window({
        title: '大数据统计-日期选择',
        layout: 'fit',       //弹出窗口内布局会充满整个窗口;
        width: 300,          //设置窗口大小;
        height: 220,
        items: panelSelect         //默认会生成Ext.Panel类型的对象;并且随窗口大小改变而改变;
    });
    windowEC.show();
}
function downloadZYL() {
    //打开下载
    if (currentService == 1) {
        window.open("./html/downloadzyl1.html?userClientNo=" + userClientNo + "&currentService=" + currentService + "&loginUsername=" + loginUsername);
    }else if (currentService == 3) {
        window.open("./html/downloadzyl3.html?userClientNo=" + userClientNo + "&currentService=" + currentService + "&loginUsername=" + loginUsername);
    } else {
        window.open("./html/downloadzylNew.html?userClientNo=" + userClientNo + "&currentService=" + currentService + "&loginUsername=" + loginUsername);
    }
}
function realTimeStatistics() {
    if (userClientNo != "00000" && userClientNo != "0000019") {
        realTimeStatisticsGetVehicleCurrentInfoDistrict();
    } else {
        realTimeAreaID = userClientNo;
        realTimeStatisticsGetVehicleCurrentInfoCity();
    }
}
function inicmbShowrealTimeStatistics() {
  if (currentService != 6) {
      return {
          icon: "images/3344.png", text: "实时在线统计",
          handler: realTimeStatisticsGetVehicleCurrentInfoCity
      };
  }
            return "";
}
function realTimeStatisticsGetVehicleCurrentInfoCity() {
    //        var carCountStore = CreateVehicleCurrentInfoDistrict();
    //        carCountStore.load({
    //            params: { clientNo: userClientNo, op: 'GetVehicleCurrentInfoCity' }, //2019.09.20 zx
    //            callback: function (records, options, success) {
    //                var carCountGrid = new Ext.grid.GridPanel({
    //                    autoSort: true,
    //                    height: 150,
    //                    columns: [
    //                    new Ext.grid.RowNumberer({
    //                        header: "",
    //                        renderer: function (value, metadata, record, rowIndex) { }
    //                    }),
    //                        { header: "区域", sortable: true, dataIndex: "type", width: 120 },
    //                        { header: "在线车辆", sortable: true, dataIndex: "carCountOnline", width: 120 },
    //                        { header: "全部车辆", sortable: true, dataIndex: "carCountAll", width: 120 }
    //                    ],
    //                    store: carCountStore,
    //                    columnLines: true
    //                });


    var tabPanel;
    if (currentService == 5) {
        tabPanel = TabPanelZONGHE();
    } else if (userClientNo == "00000") {
        tabPanel = TabPanelTianjin();
    } else if (userClientNo == "000019") {
        tabPanel = TabPanelBinhai();
    } else {
        tabPanel = new Ext.TabPanel({

            fullscreen: true,
            activeTab: 0,
            defaults: {
                styleHtmlContent: true
            },
            items: [
            {
                title: '全部',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=' + userClientNo + '&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            }
            ]
        });
    }

    var window = new Ext.Window({
        title: userName,
        layout: 'fit',       //弹出窗口内布局会充满整个窗口;
        width: 500,          //设置窗口大小;
        height: 300,
        items: tabPanel         //默认会生成Ext.Panel类型的对象;并且随窗口大小改变而改变;
    });
    window.show();
    //            }
    //        });
}

function TabPanelZONGHE() {
    return new Ext.TabPanel({
        fullscreen: true,
        activeTab: 0,
        defaults: {
            styleHtmlContent: true
        },
        items: [
            {
                title: '全部',
                //html: '<iframe src="./html/downloadzyl.html?userClientNo=0000004" width="100%" height="100%"></iframe>'
                html: '<iframe src="./html/RealTimeSynthetical.aspx?userClientNo=' + userClientNo + '&tab="width="100%" height="100%"></iframe>'
            },
            {
                title: '机扫队',
                html: '<iframe src="./html/RealTimeSynthetical.aspx?userClientNo=' + userClientNo + '&tab=机扫车"width="100%" height="100%"></iframe>'
            },
            {
                title: '清扫队',
                html: '<iframe src="./html/RealTimeSynthetical.aspx?userClientNo=' + userClientNo + '&tab=环卫队"width="100%" height="100%"></iframe>'
            },
            {
                title: '清运队',
                html: '<iframe src="./html/RealTimeSynthetical.aspx?userClientNo=' + userClientNo + '&tab=垃圾车"width="100%" height="100%"></iframe>'
            }
            ]
    });
}

function TabPanelBinhai() {
    return new Ext.TabPanel({
        fullscreen: true,
        activeTab: 0,
        defaults: {
            styleHtmlContent: true
        },
        items: [
            {
                title: '全部',
                //html: '<iframe src="./html/downloadzyl.html?userClientNo=0000004" width="100%" height="100%"></iframe>'
                html: '<iframe src="./html/RealTimeCity.aspx?userClientNo=00001901&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '塘沽',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=00001900&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '汉沽',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=00001901&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '大港',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=00001902&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '开发区',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=00001903&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '保税区',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=00001904&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '高新区',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=00001905&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '滨海中关村',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=00001906&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '生态城',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=00001907&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '东疆港',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=00001908&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            }
            ]
    });
}

function TabPanelTianjin() {
    return new Ext.TabPanel({
        fullscreen: true,
        activeTab: 0,
        defaults: {
            styleHtmlContent: true
        },
        items: [
            {
                title: '全部',
                //html: '<iframe src="/html/downloadzyl.html?userClientNo=0000004" width="100%" height="100%"></iframe>'
                html: '<iframe src="./html/RealTimeCity.aspx?userClientNo=00000&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '河西',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=0000001&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '南开',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=0000004&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '和平',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=0000005&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '河东',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=0000006&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '河北',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=0000007&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '红桥',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=0000008&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '东丽',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=0000009&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '津南',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=0000010&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '西青',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=0000011&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '北辰',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=0000012&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '蓟州',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=0000014&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '武清',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=0000015&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '静海',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=0000016&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '宁河',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=0000017&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '宝坻',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=0000018&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            },
            {
                title: '滨海',
                html: '<iframe src="./html/RealTimeDistrict.aspx?userClientNo=0000019&currentService=' + currentService + ' "width="100%" height="100%"></iframe>'
            }
            ]
    });
}

function createCarListStore() {
    carListStoreRecord = Ext.data.Record.create([
	{ name: 'VID', type: 'int' },
	{ name: 'ClientNo' },
    { name: 'ClientName' },
    { name: 'LicensePlate' },
	{ name: 'CardNo' },
	{ name: 'Lng' },
	{ name: 'Lat' },
	{ name: 'Speed', type: 'float' },
	{ name: 'Direction' },
	{ name: 'GpsTime' },
	{ name: 'CarType' },
	{ name: 'Status' },
	{ name: 'Location' },
	{ name: 'LngOffset' },
	{ name: 'LatOffset' },
    { name: 'ssection1' },
	{ name: 'ssection2' },
	{ name: 'ssection3' },
	{ name: 'ssection4' },
    { name: 'ssection5' },
    { name: 'ssection6' },
    { name: 'ssection7' },
    { name: 'ssection8' },
	{ name: 'ssection9' },
	{ name: 'ssection10' },
    { name: 'ssection11' },
	{ name: 'ssection12' },
	{ name: 'ssection13' },
	{ name: 'ssection14' },
    { name: 'ssection15' },
    { name: 'ssection16' },
    { name: 'ssection17' },
	{ name: 'ssection18' },

	{ name: 'TemperatureRT' }
    ]);

    return new Ext.data.Store({
        url: "./Json/JsonGetVehicleCurrentInfoList.ashx",
        reader: new Ext.data.JsonReader(
            {
                root: 'data'
            },
            carListStoreRecord
        )
    });

    //    return new Ext.data.Store({
    //    url: rootPath+"Services/CommonService.asmx/GetVehicleCurrentInfoList",
    //        reader: new Ext.data.XmlReader(
    //            {
    //                record: 'Result'
    //            },
    //            carListStoreRecord
    //        )
    //    });
}
function createCarGroupList() {
    var ClientStoreRecord = Ext.data.Record.create([
    { name: 'CLIENT_NAME' },
    { name: 'CLIENT_NO' }
    ]);
    // 数据源
    return new Ext.data.Store({
        url: "./Json/JsonGetVehicleCurrentInfoList.ashx",
        autoSync: false,
        reader: new Ext.data.JsonReader({ root: 'data' }, ClientStoreRecord)
    });
}
function createVideoLoginInfo() {
    var videoInfo = Ext.data.Record.create([
    { name: 'id' },
    { name: 'pword' }
    ]);
    // 数据源
    return new Ext.data.Store({
        url: "./Json/JsonGetVehicleCurrentInfoList.ashx",
        autoSync: false,
        reader: new Ext.data.JsonReader({ root: 'data' }, videoInfo)
    });
}
function CreateVehicleCurrentInfoDistrict() {
    var videoInfo = Ext.data.Record.create([
    { name: 'type' },
    { name: 'carCountOnline' },
    { name: 'carCountAll' }
    ]);
    // 数据源
    return new Ext.data.Store({
        url: "./Json/JsonGetVehicleCurrentInfoList.ashx",
        pageSize: 2,
        autoSync: false,
        reader: new Ext.data.JsonReader({ root: 'data' }, videoInfo)
    });
}

function CreatePlaceData() {
    var placeData = Ext.data.Record.create([
    { name: 'ID' },
    { name: 'Name' },
    { name: 'LOACTION' },
    { name: 'DISTRICT' },
    { name: 'TYPE' },
    { name: 'SIZE' },
    { name: 'LONGITUDE' },
    { name: 'LATITUDE' }
    ]);
    // 数据源
    return new Ext.data.Store({
        url: "./Json/JsonGetVehicleCurrentInfoList.ashx",
        //        pageSize: 2,
        autoSync: false,
        reader: new Ext.data.JsonReader({ root: 'data' }, placeData)
    });
}